﻿@using System.Web.Routing
@using System.Web.Mvc.Html
@helper DoPager(System.Web.Mvc.HtmlHelper hh, string pageActionName, WebGrid grid, int maxPageLinks, object rvd)
    {
    <div class="page">
        <table width="100%">
            <tr>
                <td>
                    Page <b>@(grid.PageIndex + 1)</b> of <b>@grid.PageCount</b>
                </td>
                <td align="right">
                    @if (grid.PageCount > 1)
                    {
                        <ul id="pagination-digg">
                            <li>
                                @{ RouteValueDictionary rvdp1 = new RouteValueDictionary(rvd);
                                   rvdp1.Add("Page", 1);
                                }
                                @hh.ActionLink("<<", pageActionName, rvdp1)
                            </li>
                            @{ int start = Math.Max(0, grid.PageIndex - maxPageLinks / 2); }
                            @for (int ix = 0; ix + start < grid.PageCount; ix++)
                            {
                                int pageno = start + ix + 1;
                                var css = hh.Raw(pageno - 1 == grid.PageIndex ? " class=\"active\"" : "");
                                RouteValueDictionary rvdp = new RouteValueDictionary(rvd);
                                rvdp.Add("Page", pageno);
                                <li@css>
                                    @hh.ActionLink(pageno.ToString(), pageActionName, rvdp)
                                </li>
                                if (ix >= maxPageLinks) { break; }
                            }
                            <li>
                                @{ RouteValueDictionary rvdpX = new RouteValueDictionary(rvd);
                                   rvdpX.Add("Page", grid.PageCount);
                                }
                                @hh.ActionLink(">>", pageActionName, rvdpX)
                            </li>
                        </ul>
                    }
                </td>
            </tr>
        </table>
    </div>
}
@using System.Web.Mvc.Ajax
@helper DoAjaxPager(System.Web.Mvc.AjaxHelper aa, System.Web.Mvc.Ajax.AjaxOptions aopts, System.Web.Mvc.HtmlHelper hh, string pageActionName, WebGrid grid, int maxPageLinks, object rvd)
    {
    <div class="pager">
        <table width="100%">
            <tr>
                <td>
                    Page <b>@(grid.PageIndex + 1)</b> of <b>@grid.PageCount</b>
                </td>
                <td align="right">
                    @if (grid.PageCount > 1)
                    {
                        <ul id="pagination-digg">
                            <li>
                                @{ RouteValueDictionary rvdp1 = new RouteValueDictionary(rvd);
                                   rvdp1.Add("Page", 1);
                                }
                                @aa.ActionLink("<<", pageActionName, rvdp1, aopts)
                            </li>
                            @{ int start = Math.Max(0, grid.PageIndex - maxPageLinks / 2); }
                            @for (int ix = 0; ix + start < grid.PageCount; ix++)
                            {
                                int pageno = start + ix + 1;
                                var css = hh.Raw(pageno - 1 == grid.PageIndex ? " class=\"active\"" : "");
                                RouteValueDictionary rvdp = new RouteValueDictionary(rvd);
                                rvdp.Add("Page", pageno);
                                <li@css>
                                    @aa.ActionLink(pageno.ToString(), pageActionName, rvdp, aopts)
                                </li>
                                if (ix >= maxPageLinks) { break; }
                            }
                            <li>
                                @{ RouteValueDictionary rvdpX = new RouteValueDictionary(rvd);
                                   rvdpX.Add("Page", grid.PageCount);
                                }
                                @aa.ActionLink(">>", pageActionName, rvdpX, aopts)
                            </li>
                        </ul>
                    }
                </td>
            </tr>
        </table>
    </div>
}

@using Domain.Entity
@using System.Web.Mvc
@helper PaymentLink(UrlHelper url, dynamic item)
{
    if (item.Status.Type.Contains("Pending")){
        <a href="@url.Action("ConfirmPayment", "Invoice", new { id = item.id })" >Pay</a>
    }
    else          {
        <a href="@url.Action("ConfirmPayment", "Invoice", new { id = item.id })" >Edit</a>
    }
}
